<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Insert title here</title>
<script type="text/javascript" src="js/jquery-1.8.3.js"></script>
<script type="text/javascript">
	function check() {
		var name=$("#name").val();
		var breed=$("#breed").val();
		var birthday=$("#birthday").val();
		if (name=="" || name==null) {
			alert("昵称不能为空!");
			return false;
		}
		if (breed==0) {
			alert("品种不能为空!");
			return false;
		}
		if (birthday=="" || !(isNaN(birthday) && !isNaN(Date.parse(birthday)))) {
			alert("日期格式不正确");
			return false;
		}
		return true;
	}
	$(function(){
		$("#name").blur(function(){
			var name=this.value;
			$.get("ExitsNameServlet","name="+name,function(data){
				if (data==1) {
					alert("昵称已存在");
					return false;
				}
			})
		})
	});
</script>
</head>
<body>
<form action="AddServlet" method="post" onsubmit="return check();">
<h3 style="text-align: center;">宠物的基本信息</h3>
昵称:<input type="text" name="name" id="name"><br><br>
品种:<select name="breed" id="breed">
		<option value="0">请选择</option>
		<option value="1">狗</option>
		<option value="2">猫</option>
		<option value="3">鸟</option>
		<option value="4">兔</option>
	</select><br><br>
性别:<input type="radio" name="sex" value="1" checked="checked">雄 <input type="radio" name="sex" value="1">雌<br>
出生日期:<input type="text" name="birthday" id="birthday">yyyy-MM-dd<br><br>
宠物描述:<textarea rows="5" cols="30" name="description"></textarea>
<p style="text-align: center;"><input type="submit" value="提交">&nbsp;&nbsp;&nbsp;<input type="reset" value="重置"></p>
</form>
</body>
</html>